{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "180010c8",
   "metadata": {},
   "source": [
    "# Parameter `alphaStroke` in `geomLabel()`\n",
    "\n",
    "Use the `alphaStroke` parameter to enable the applying of `alpha` to `color` (label text and border)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f81c6ec0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"BmmHNO\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"library\">\n",
       "       if(!window.letsPlotCallQueue) {\n",
       "           window.letsPlotCallQueue = [];\n",
       "       }; \n",
       "       window.letsPlotCall = function(f) {\n",
       "           window.letsPlotCallQueue.push(f);\n",
       "       };\n",
       "       (function() {\n",
       "           var script = document.createElement(\"script\");\n",
       "           script.type = \"text/javascript\";\n",
       "           script.src = \"https://cdn.jsdelivr.net/gh/JetBrains/lets-plot@v4.3.0rc1/js-package/distr/lets-plot.min.js\";\n",
       "           script.onload = function() {\n",
       "               window.letsPlotCall = function(f) {f();};\n",
       "               window.letsPlotCallQueue.forEach(function(f) {f();});\n",
       "               window.letsPlotCallQueue = [];\n",
       "               \n",
       "               \n",
       "           };\n",
       "           script.onerror = function(event) {\n",
       "               window.letsPlotCall = function(f) {};\n",
       "               window.letsPlotCallQueue = [];\n",
       "               var div = document.createElement(\"div\");\n",
       "               div.style.color = 'darkred';\n",
       "               div.textContent = 'Error loading Lets-Plot JS';\n",
       "               document.getElementById(\"BmmHNO\").appendChild(div);\n",
       "           };\n",
       "           var e = document.getElementById(\"BmmHNO\");\n",
       "           e.appendChild(script);\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%useLatestDescriptors\n",
    "%use lets-plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "f3d9289c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Lets-Plot Kotlin API v.0.0.0-SNAPSHOT. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.3.0rc1."
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "LetsPlot.getInfo()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a19b45c2",
   "metadata": {},
   "outputs": [],
   "source": [
    "val x = (1..10).toList()\n",
    "val y = x.reversed()\n",
    "\n",
    "val data = mapOf(\"x\" to x, \"y\" to y, \"alpha\" to x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "0710fdc6",
   "metadata": {},
   "outputs": [],
   "source": [
    "val p = letsPlot(data) { x = \"x\"; y = \"y\"; alpha = \"y\" } +\n",
    "    geomBar(stat = Stat.identity, fill = \"#2b8cbe\", tooltips = tooltipsNone) + \n",
    "    guides(alpha = \"none\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "48c32374",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"RtdaEw\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\",\n",
       "\"alpha\":\"y\"\n",
       "},\n",
       "\"guides\":{\n",
       "\"alpha\":\"none\"\n",
       "},\n",
       "\"data\":{\n",
       "\"x\":[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0],\n",
       "\"y\":[10.0,9.0,8.0,7.0,6.0,5.0,4.0,3.0,2.0,1.0]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"stack\",\n",
       "\"geom\":\"bar\",\n",
       "\"fill\":\"#2b8cbe\",\n",
       "\"tooltips\":\"none\",\n",
       "\"data\":{\n",
       "}\n",
       "},{\n",
       "\"nudge_y\":1.0,\n",
       "\"mapping\":{\n",
       "\"label\":\"y\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"label_format\":\".1f\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"label\",\n",
       "\"fill\":\"#2b8cbe\",\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"RtdaEw\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();    \n",
       "   </script>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p + geomLabel(nudgeY = 1, labelFormat = \".1f\", fill = \"#2b8cbe\") { label = \"y\" }"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bcde9884",
   "metadata": {},
   "source": [
    "#### Use `alphaStroke` Parameter to Apply `alpha` to `color`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "031cd642",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"UjuxE8\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "       (function() {\n",
       "           var plotSpec={\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\",\n",
       "\"alpha\":\"y\"\n",
       "},\n",
       "\"guides\":{\n",
       "\"alpha\":\"none\"\n",
       "},\n",
       "\"data\":{\n",
       "\"x\":[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0],\n",
       "\"y\":[10.0,9.0,8.0,7.0,6.0,5.0,4.0,3.0,2.0,1.0]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"stack\",\n",
       "\"geom\":\"bar\",\n",
       "\"fill\":\"#2b8cbe\",\n",
       "\"tooltips\":\"none\",\n",
       "\"data\":{\n",
       "}\n",
       "},{\n",
       "\"nudge_y\":1.0,\n",
       "\"mapping\":{\n",
       "\"label\":\"y\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"label_format\":\".1f\",\n",
       "\"alpha_stroke\":true,\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"label\",\n",
       "\"fill\":\"#2b8cbe\",\n",
       "\"data\":{\n",
       "}\n",
       "}]\n",
       "};\n",
       "           var plotContainer = document.getElementById(\"UjuxE8\");\n",
       "           window.letsPlotCall(function() {{\n",
       "               LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer);\n",
       "           }});\n",
       "       })();    \n",
       "   </script>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p + geomLabel(nudgeY = 1, labelFormat = \".1f\", fill = \"#2b8cbe\", alphaStroke = true) { label = \"y\" }"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Kotlin",
   "language": "kotlin",
   "name": "kotlin"
  },
  "language_info": {
   "codemirror_mode": "text/x-kotlin",
   "file_extension": ".kt",
   "mimetype": "text/x-kotlin",
   "name": "kotlin",
   "nbconvert_exporter": "",
   "pygments_lexer": "kotlin",
   "version": "1.8.0-dev-3517"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
